<template>
	<view class="fruit-admin-add-kind-container">
		<view class="fruit-admin-add-kind-item">
			<textarea placeholder="请输入种类名称" v-model="data.name" ></textarea>
		</view>
	</view>
	<button @tap="addKind">确认添加</button>
</template>

<script>
	import {reactive} from 'vue'
	import global from "../../config/global.js"
	export default {
		name:"fruit-admin-add-kind",
		setup(){
			let data = reactive({
				name:""
			})
			
			function addKind(){
				uni.request({
					url:`${global.BASE_URL}/fruit/addFruitKind`,
					method:"POST",
					data:{
						"name":data.name
					},
					header:{
						"mytoken":uni.getStorageSync("localtoken")
					},
					success: (res) => {
						console.log(res)
						if(res.data.code){
							uni.navigateBack()
						}
					},
					fail: (err) => {
						console.log(err)
					}
				})
			}
			
			return {
				data,
				addKind
			}
		}
	}
</script>

<style scoped lang="scss">
	.fruit-admin-add-kind-container{
		width: 680rpx;
		margin: 15rpx 35rpx;
		
		& .fruit-admin-add-kind-item{
			margin: 20rpx 0;
			padding: 10rpx 0;
			border-bottom: 1rpx solid #bbbbbb;
			
			& textarea{
				font-size: 35rpx;
				width: 660rpx;
				line-height: 45rpx;
				height: 135rpx;
				padding: 0 10rpx;
			}
		}
	}
	
	button{
		background-color: #9BCDD2;
		color: white;
		width: 400rpx;
		margin: 50rpx 175rpx 10rpx 175rpx;
		height: 70rpx;
		line-height: 70rpx;
		font-size: 35rpx;
		// font-weight: bold;
	}
</style>
